import req from "../../req";
import { CountryItem, ImportGeoReq, PartialZoneItem, RegionsItem, SearchChildCity, ZoneItem } from "./models";

export enum Api {
  getCountry = "api/system/regions/getCountry",
  getRegionsByParentId = "api/system/regions/getRegionsByParentId",
  getRegionsCodeAndSave = "api/system/regions/getRegionsCodeAndSave",
  importGeo = "api/system/regions/importGeo",
}

export function getRegionsCodeAndSave(data: RegionsItem) {
  return req.post<boolean>(
    {
      url: Api.getRegionsCodeAndSave,
      data,
    },
    {
      useGlobalLoading: false,
    }
  );
}

export function getCountry() {
  return req.get<CountryItem[]>(
    {
      url: Api.getCountry,
    },
    {
      useGlobalLoading: false,
    }
  );
}
export function getRegionsByParentId(params: SearchChildCity) {
  return req.get<PartialZoneItem[]>(
    {
      url: Api.getRegionsByParentId,
      params,
    },
    {
      useGlobalLoading: false,
    }
  );
}
export function importGeo(data: ImportGeoReq) {
  return req.post<boolean>(
    {
      url: Api.importGeo,
      data,
    },
    {
      useGlobalLoading: false,
    }
  );
}
